using System;

namespace CoreLibrary.Messaging {

    public class Message {

        public string Id                { get; set; }
        public int ApplicationId        { get; set; }
        public string Data              { get; set; }
        public string Fault             { get; set; }
        public int Retry                { get; set; }
        public MessageStatus Status     { get; set; }
        public MessagePriority Priority { get; set; }
        public DateTime DateCreated     { get; set; }
        public DateTime DateScheduled   { get; set; }

        public override bool Equals(object obj) {
            if (obj == null) {
                return false;
            }
            if (ReferenceEquals(obj, this)) {
                return true;
            }
            if (obj.GetType() != typeof(Message)) {
                return false;
            }
            var msgId = ((Message)obj).Id;
            return Equals(msgId, Id);
        }

        public override int GetHashCode() {
            return (Id != null ? Id.GetHashCode() : 0);
        }

    }
}